//
//  HomeModelSelectView.m
//  DigitalFlip
//
//  Created by 蓝鳍互娱 on 2024/1/31.
//

#import "HomeModelSelectView.h"
#import "Public.h"

@interface HomeModelSelectView()
@property (nonatomic,strong) UIButton *leftModelSelectBtn;
@property (nonatomic,strong) UIButton *rightModelSelectBtn;
@property (nonatomic,strong) UILabel *selectLab;

@property (nonatomic,strong) NSArray *types;
@property (nonatomic,assign) int type;

@end
@implementation HomeModelSelectView
-(instancetype)init{
    if(self == [super init]){
        self.types = @[@"Simple",@"Medium",@"difficulty"];
        self.type = 0;
        [self creatSubView];
    }
    return self;
}
- (void)creatSubView{
    self.leftModelSelectBtn = [[UIButton alloc] init];
    [self.leftModelSelectBtn setBackgroundImage:DFImageNamed(@"homeHeadleftIcon") forState:UIControlStateNormal];
    [self.leftModelSelectBtn addTarget:self action:@selector(leftModelSelect) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.leftModelSelectBtn];
    [self.leftModelSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(ScreenAutoScale(0)));
        make.top.equalTo(@(ScreenAutoScale(0)));
        make.bottom.equalTo(@(ScreenAutoScale(0)));
        make.width.equalTo(self.leftModelSelectBtn.mas_height);
    }];
    self.rightModelSelectBtn = [[UIButton alloc] init];
    [self.rightModelSelectBtn setBackgroundImage:DFImageNamed(@"homeHeadRightIcon") forState:UIControlStateNormal];
    [self.rightModelSelectBtn addTarget:self action:@selector(rightModelSelect) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.rightModelSelectBtn];
    [self.rightModelSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(ScreenAutoScale(0)));
        make.top.equalTo(@(ScreenAutoScale(0)));
        make.bottom.equalTo(@(ScreenAutoScale(0)));
        make.width.equalTo(self.rightModelSelectBtn.mas_height);
    }];
    self.selectLab = [[UILabel alloc] init];
    self.selectLab.font = [UIFont systemFontOfSize:20 weight:UIFontWeightRegular];
    self.selectLab.textColor = df_ColorRGB(0xFFFFFF);
    self.selectLab.textAlignment = NSTextAlignmentCenter;
    self.selectLab.text = self.types[self.type];
    [self addSubview:self.selectLab];
    [self.selectLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftModelSelectBtn.mas_right);
        make.right.equalTo(self.rightModelSelectBtn.mas_left);
        make.top.equalTo(@(ScreenAutoScale(0)));
        make.bottom.equalTo(@(ScreenAutoScale(0)));
    }];
}
- (void)leftModelSelect{
    self.type --;
    if(self.type < 0){
        self.type = 2;
    }
    self.selectLab.text = self.types[self.type];
}
- (void)rightModelSelect{
    self.type ++;
    if(self.type > 2){
        self.type = 0;
    }
    self.selectLab.text = self.types[self.type];
}
@end
